<template>
  <Page header="重要通知" is-back>
    <u-empty v-if="!dataList.length" text="暂无数据" mode="list"></u-empty>
    <scroll-view scroll-y="true" @scrolltolower="onScroll" style="height: 100%">
      <view v-for="(item, index) in dataList" :key="index">
        <view class="flex flex-direction-column background-color-white"
              style="border-radius: 16rpx; margin: 32rpx 32rpx 32rpx; padding: 40rpx 36rpx;"
              @click="toDetail(item)">
          <text style=" color: #3d3d3d; font-size: 32rpx;font-weight:bold">{{item.title}}</text>
          <view style="height: 54rpx;"></view>
          <view class="flex" style="font-family: DIN;">
            <u-image height="26" width="26" src="/static/images/home/sj@1.5x.png"
                     style="margin-right: 18rpx"></u-image>
            <div style="font-size: 28rpx;line-height: 26rpx;color: #ADADAD"> {{ item.time }}</div>
          </view>
        </view>
      </view>
      <u-loadmore v-if="dataList.length" :status="loading" />
      <div style="height: 40rpx"></div>
    </scroll-view>
  </Page>
</template>
<script>
import Page from "../../components/Page.vue";
import mixin from "../../common/mixin.js";
export default {
  name: "index",
  mixins: [mixin],
  components: { Page},
  data() {
    return {}
  },
  onLoad() {
    this.getList()
  },
  methods: {
    toDetail(item) {
      console.log(item)
      uni.navigateTo({
        url: `/pages/notice/detail?id=${item.id}`
      })
    },
    getList() {
      uni.showLoading({
        title: '加载中',
        mask: true,
        duration: 0
      })
      this.$api.getNoticePage({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      }).then(res => {
        this.totalCount = res.rows.count
        let list = []
        res.rows.forEach(item => {
          list.push({
            ...item
          })
        })
        if (this.pageNum === 1) {
          this.dataList = [
          ]
        }
        this.dataList = [
          ...this.dataList,
          ...list
        ]
        if (this.pageNum >= this.totalPage) {
          this.loading = 'nomore'
        } else {
          this.loading = 'loadmore'
        }
      }).finally(() => {
        uni.hideLoading()
      })
    }
  }
}
</script>

<style lang="scss">
</style>
